package com.mall.product.web;

import com.mall.product.entity.CategoryEntity;
import com.mall.product.service.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;


import java.util.List;

@Controller
public class IndexController {


    @Autowired
    private CategoryService categoryService;

    @GetMapping({"/","/index.html"})
    public String getIndex(Model model){
      List<CategoryEntity> categoryEntityList =  categoryService.getFirstLevel();
      model.addAttribute("categories", categoryEntityList);
      return "index";
    }

    //http://localhost:8091/index/catalog.json
}
